﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>客户管理</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js" type="text/javascript"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <style type="text/css">
    </style>
    <script>
        var model = avalon.define({
            $id: "USUERKHRZLIST",
            KHContent: "",
            CommonData: [],
            SelKH: [],
            KHTypeData: [],
            GetKHType: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: 8 }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.KHTypeData = resultData.Result;
                    }
                })
            },
            GetKHData: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETUSERKHGLDATA', { P1: model.KHType, P2: model.KHContent, b: "" }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData = resultData.Result;
                    }
                })
            },
            CheckALL: function (dom) {
                var removeCla = "fa-square-o";
                var addCla = "fa-check-square-o";
                if ($(dom).hasClass(removeCla)) {
                    $(dom).removeClass(removeCla).addClass(addCla);
                    $("#khgl tbody  tr td i").removeClass(removeCla).addClass(addCla);
                    model.SelKH = model.CommonData;
                } else {
                    $(dom).removeClass(addCla).addClass(removeCla);
                    $("#khgl tbody tr td i").removeClass(addCla).addClass(removeCla);
                    model.SelKH = [];
                }
            }, CheckKH: function (dom, item) {
                var removeCla = "fa-square-o";
                var addCla = "fa-check-square-o";
                if ($(dom).hasClass(removeCla)) {
                    $(dom).removeClass(removeCla).addClass(addCla);
                    model.SelKH.push(item);
                } else {
                    $(dom).removeClass(addCla).addClass(removeCla);
                    model.SelKH.remove(item);
                }
            }, GetCheckPhone: function () {
                var phone = "";
                model.SelKH.$model.forEach(function (val,i) {
                    if (val.KHPhone) {

                        phone += val.KHPhone + ",";
                    }
                })
                return phone.split(",").length > 0 ? phone.substring(0, phone.length - 1) : phone;
            }
        });
        avalon.ready(function () {
            model.GetKHType();
            model.GetKHData();

        })

    </script>
</head>
<body ms-controller="USUERKHRZLIST">
    <div class="container-fluid maindiv" style="margin-top: 20px; margin-left:20px;" id="dvContent">
        <div class="row contentdv">
            <div class="col-xs-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-xs-9">
                                <div class="input-group">
                                    <div class="input-group-addon">查询条件</div>
                                    <select class="form-control" ms-duplex="KHType" style="width:30%" ms-change="GetKHData()">
                                        <option value="">全部客户类别</option>
                                        <option ms-attr-val="item.TypeNO" ms-repeat-item="KHTypeData">{{item.TypeNO}}</option>
                                    </select>
                                    <input id="tbSearch" class="form-control" style="width:70%" type="text" ms-duplex="KHContent" placeholder="输入客户姓名,单位名称,联系号码查询" />
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" ms-click="GetKHData()">查询</button>
                                    </span>
                                </div>
                            </div>
                            <div class="col-xs-3 text-right">
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <table class="table table-bordered table-hover table-striped" id="khgl">
            <thead>
                <tr>
                    <th class="text-center"><i class="fa fa-square-o" ms-click="CheckALL(this)"></i></th>
                    <th class="text-center">客户姓名</th>
                    <th class="text-center">客户性别</th>
                    <th class="text-center">客户电话</th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-item="CommonData">
                    <td class="text-center"><i class="fa fa-square-o" ms-click="CheckKH(this,item)"></i></td>
                    <td>{{item.KHName}}</td>
                    <td>{{item.KHXinBie}}</td>
                    <td>{{item.KHPhone}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>
